//
//  AddressController.m
//  LiquorChain
//
//  Created by apple on 2019/1/2.
//  Copyright © 2019年 王冬. All rights reserved.
//

#import "AddressController.h"
#import "AddAdressViewCell.h"
@interface AddressController ()<UITextFieldDelegate,UITextViewDelegate>
///用户名
@property (nonatomic,strong) UITextField *nameTextfiled;
/// 电话
@property (nonatomic,strong) UITextField *phoneTextfiled;
/// 省市区
@property (nonatomic,strong) UITextField *proCityTextfiled;
/// 详细地址
@property (nonatomic,strong) UITextView *addressTextView;
/// 提交
@property (nonatomic,strong) UIButton *commitBtn;
@end

@implementation AddressController

static NSString *CellIdentifier = @"addadressCell";
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"添加地址";
    self.view.backgroundColor =BACKGROUNDCOLOR;
    
    UIView *headView =[[UIView alloc]init];
    [self.view addSubview:headView];
    headView.backgroundColor =[UIColor whiteColor];
    [headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(kNavBarHeight +15);
        make.height.mas_equalTo(101);
    }];
    UILabel *nameLabel =[[UILabel alloc]init];
    [headView addSubview:nameLabel];
    nameLabel.text = @"姓名";
    nameLabel.font =[UIFont systemFontOfSize:14];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(10);
        make.width.mas_equalTo(30);
        make.height.mas_equalTo(30);
    }];
    self.nameTextfiled =[[UITextField alloc]init];
    [headView addSubview:self.nameTextfiled];
    self.nameTextfiled.placeholder = @"请输入收件人姓名";
    self.nameTextfiled.font =[UIFont systemFontOfSize:14];
    [self.nameTextfiled mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel.mas_right).with.offset(20);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(10);
        make.height.mas_equalTo(30);
    }];
    UILabel *lineLabel =[[UILabel alloc]init];
    [headView addSubview:lineLabel];
    lineLabel.backgroundColor =BACKGROUNDCOLOR;
    [lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(50);
        make.height.mas_equalTo(0.4);
    }];
    
    UILabel *phoneLabel =[[UILabel alloc]init];
    [headView addSubview:phoneLabel];
    phoneLabel.text = @"电话";
    phoneLabel.font =[UIFont systemFontOfSize:14];
    [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(61);
        make.width.mas_equalTo(30);
        make.height.mas_equalTo(30);
    }];
    self.phoneTextfiled =[[UITextField alloc]init];
    [headView addSubview:self.phoneTextfiled];
    self.phoneTextfiled.placeholder = @"请输入收件人手机号";
    self.phoneTextfiled.font =[UIFont systemFontOfSize:14];
    [self.phoneTextfiled mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(phoneLabel.mas_right).with.offset(20);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(61);
        make.height.mas_equalTo(30);
    }];
    UIView *bodyView =[[UIView alloc]init];
    bodyView.backgroundColor =[UIColor whiteColor];
    [self.view addSubview:bodyView];
    [bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(headView.mas_bottom).with.offset(20);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(170);
    }];
    UILabel *proCityLabel =[[UILabel alloc]init];
    [bodyView addSubview:proCityLabel];
    proCityLabel.text = @"省市区";
    proCityLabel.font =[UIFont systemFontOfSize:14];
    [proCityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(10);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(30);
    }];
    self.proCityTextfiled =[[UITextField alloc]init];
    [bodyView addSubview:self.proCityTextfiled];
    self.proCityTextfiled.placeholder = @"请选择省市区";
    self.proCityTextfiled.font =[UIFont systemFontOfSize:14];
    self.proCityTextfiled.delegate = self;
    [self.proCityTextfiled mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(proCityLabel.mas_right).with.offset(20);
        make.right.mas_equalTo(-40);
        make.top.mas_equalTo(10);
        make.height.mas_equalTo(30);
    }];
    UIButton *rightBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    [bodyView addSubview:rightBtn];
    [rightBtn setImage:[UIImage imageNamed:@"you"] forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(rightClick:) forControlEvents:UIControlEventTouchUpInside];
    [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(10);
        make.width.height.mas_equalTo(30);
    }];
    UILabel *lineLabel1 =[[UILabel alloc]init];
    [bodyView addSubview:lineLabel1];
    lineLabel1.backgroundColor =BACKGROUNDCOLOR;
    [lineLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(50);
        make.height.mas_equalTo(0.4);
    }];
    
    
    UILabel *adressLabel =[[UILabel alloc]init];
    [bodyView addSubview:adressLabel];
    adressLabel.text = @"详细地址";
    adressLabel.font =[UIFont systemFontOfSize:14];
    [adressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(61);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(30);
    }];
    self.addressTextView =[[UITextView alloc]init];
    [bodyView addSubview:self.addressTextView];
    
   self.addressTextView.backgroundColor= [UIColor whiteColor];
   self.addressTextView.placeholder = @"请输入详细地址";
    self.addressTextView.font =[UIFont systemFontOfSize:14];
    [self.addressTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(adressLabel.mas_right).with.offset(10);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(61);
        make.bottom.mas_equalTo(-10);
    }];
    
  
    self.commitBtn =[UIButton buttonWithType:UIButtonTypeCustom];
    [self.view  addSubview:self.commitBtn];
    [self.commitBtn setTitle:@"确认" forState:UIControlStateNormal];
    [self.commitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.commitBtn.backgroundColor = CUSTOMCOLOR;
    self.commitBtn.layer.cornerRadius = 5;
    [self.commitBtn addTarget:self action:@selector(commitClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(bodyView.mas_bottom).with.offset(40);
        make.height.mas_equalTo(50);
    }];
    
    
    // Do any additional setup after loading the view.
}
///
-(void)commitClick:(UIButton *)sender{
    NSLog(@"确认");
}
-(void)rightClick:(UIButton *)sender{
    NSLog(@"选择省市区");
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    NSLog(@"这里返回为NO。则为禁止编辑");
    return NO;
}

//
//#pragma mark - UITextViewDelegate
//- (void)textViewDidEndEditing:(UITextView *)textView
//{
//    if(textView.text.length < 1){
//        textView.text = @"请输入详细地址";
//        textView.textColor = RGBA(197, 197, 197, 1);
//    }
//}
//- (void)textViewDidBeginEditing:(UITextView *)textView
//{
//    if([textView.text isEqualToString:@"请输入详细地址"]){
//        textView.text=@"";
//        textView.textColor=[UIColor blackColor];
//    }
//}

//-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
//    return 2;
//}
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    return 2;
//}
//-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
//    if (section ==0) {
//        UIView *aa =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 20)];
//        ///aa.backgroundColor =[UIColor redColor];
//        return aa;
//    }else{
//
//        UIView *footView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 100)];
//       /// footView.backgroundColor =[UIColor greenColor];
//
//        UIButton *commitBtn =[UIButton buttonWithType:UIButtonTypeCustom];
//        [footView addSubview:commitBtn];
//        [commitBtn setTitle:@"确定" forState:UIControlStateNormal];
//        [commitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        commitBtn.layer.cornerRadius = 5;
//        commitBtn.backgroundColor = CUSTOMCOLOR;
//        [commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.mas_equalTo(25);
//            make.left.mas_equalTo(14);
//            make.right.mas_equalTo(-14);
//            make.height.mas_equalTo(50);
//        }];
//        return footView;
//    }
//}
//-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
//    if (section ==0) {
//        return 20;
//    }else{
//        return 100;
//    }
//
//}
//-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    if (indexPath.section ==1) {
//        if (indexPath.row==1) {
//            return 120;
//        }else{
//            return 50;
//        }
//    }else{
//        return 50;
//    }
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//    AddAdressViewCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//    if (indexPath.section ==0) {
//        if (indexPath.row ==0) {
//            cell.titleLabel.text = @"姓名";
//            cell.contentText.placeholder = @"请输入收件人姓名";
//        }
//        if (indexPath.row ==1) {
//            cell.titleLabel.text = @"电话";
//            cell.contentText.placeholder = @"请输入收件人手机号";
//        }
//
//    }
//    if (indexPath.section ==1) {
//
//        if (indexPath.row ==0) {
//            cell.titleLabel.text = @"省市区";
//            cell.contentText.placeholder = @"请选择省市区";
//        }
//        if (indexPath.row ==1) {
//            cell.titleLabel.text = @"详细地址";
//            cell.contentText.placeholder = @"请输入详细地址";
//        }
//    }
//    return cell;
//}

@end
